﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO;
namespace CricketHub
{
    public class Schedule_web
    {

        public Schedule1 schd;
        HttpWebRequest req;
        public void schedule_teams()
        {
            try
            {
                req = (HttpWebRequest)WebRequest.Create("http://synd.cricbuzz.com/j2me/1.0/sch_calender.xml");
                IAsyncResult result = (IAsyncResult)req.BeginGetResponse(new AsyncCallback(Resp), this);
            }
            catch (Exception ee)
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        MessageBox.Show("Please check the Network Connection");
                    });
            }

        }
        private void Resp(IAsyncResult asyn)
        {
            try
            {
                Schedule_web obj = (Schedule_web)asyn.AsyncState;
                HttpWebRequest req2 = req;
                HttpWebResponse response = (HttpWebResponse)req2.EndGetResponse(asyn);
                Stream strea = response.GetResponseStream();
                StreamReader reader = new StreamReader(strea);
                string schedule = reader.ReadToEnd();

                schd.Scudule_data(schedule);
            }
            catch (Exception ee)
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    MessageBox.Show("Please check the Network Connection");
                });
            }

        }



    }
}
